package com.spyx.acl.service.impl;

import com.atyx.spyx.model.acl.Admin;
import com.atyx.spyx.vo.acl.AdminQueryVo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.spyx.acl.mapper.AdminMapper;
import com.spyx.acl.service.AdminService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements AdminService {
    @Override
    public IPage<Admin> selectList(Page p1, AdminQueryVo queryVo) {

        //创建模糊查条件
        String username = queryVo.getUsername();
        LambdaQueryWrapper<Admin> wrapper = new LambdaQueryWrapper<>();
        if(!StringUtils.isEmpty(username)){  //非空验证
            wrapper.like(Admin::getUsername,username);
        }
        //调取分页查询方法
        IPage<Admin> iPage= baseMapper.selectPage(p1,wrapper);

        return iPage;
    }
}
